package org.ravey.plugin;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.UUID;


public class PluginGenerator {


	
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		
		if(args.length < 1){
			System.out.println("Usage: java PluginGenerator [InfoFilePath]");
			System.exit(0);
		}
		
		//might introduce commandline stuff for this later so set them all to null to start
		String PluginJarFile=null;
		String PluginTitle=null;
		String PluginAuthor=null;
		String PluginMainClass=null;
		
		//Define the kernel version
		int KernelVersion = 1;
		
		//create an input stream reader
		InputStreamReader ir = new InputStreamReader(System.in);
		//create a buffered reader for the input stream reader
		BufferedReader br = new BufferedReader(ir);
		
		
		System.out.println("Welcome to the plugin generation wizard. I'm going to ask you" +
				" some questions and then generate a plugin info file for you.");
		
		//first lets do the jarfile path
		System.out.println("What is the path of the plugin jarfile? >>");
		try {
			PluginJarFile = br.readLine();
		} catch (IOException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		
		//now the pluginTitle
		System.out.println("What is the title of your plugin? >>");
		try {
			PluginTitle = br.readLine();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		//now the pluginAuthor
		System.out.println("What is the author's name? >>");
		try {
			PluginAuthor = br.readLine();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
		//finally, the main class
		System.out.println("What is the name of the main class of this plugin? >>");
		try {
			PluginMainClass = br.readLine();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		System.out.println("Thanks, now I'm going to generate a UUID for your plugin");
		UUID id = UUID.randomUUID();
		
		System.out.println("Generating plugin info file...");
		PluginInfo pluginInfo = new PluginInfo(id.toString(), PluginTitle, PluginAuthor, PluginMainClass,PluginJarFile, KernelVersion);
		 
		System.out.println("Saving plugin info file...");
		try {
			pluginInfo.SaveInfo(args[0]);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

}
